/*
 * http.h
 *
 * Copyright (C) 2011 - Dr.NP
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */

/**
 * @version http.h 1.0.0
 * @package libbspehttp
 * @author Dr.NP <np@bsgroup.org>
 * @update 05/17/2011
 */

#ifndef BSP_EXT_HTTP_H

#define BSP_EXT_HTTP_H                          1

// Definations
#define FREE_REQUEST_LIST_INITIAL               1024

#define SERVER_ID                               "BS.Play web service 1.0 (Linux)"

#define HTTP_STATUS_CONTINUE                    100
#define HTTP_STATUS_SWITCHING                   101
#define HTTP_STATUS_OK                          200
#define HTTP_STATUS_CREATED                     201
#define HTTP_STATUS_ACCEPTED                    202
#define HTTP_STATUS_NON_AUTHORITATIVE           203
#define HTTP_STATUS_NO_CONTENT                  204
#define HTTP_STATUS_RESET_CONTENT               205
#define HTTP_STATUS_PARTIAL_CONTENT             206
#define HTTP_STATUS_MULTIPLE_CHOICES            300
#define HTTP_STATUS_MOVED_PERMANENTLY           301
#define HTTP_STATUS_FOUND                       302
#define HTTP_STATUS_SEE_OTHER                   303
#define HTTP_STATUS_NOT_MODIFIED                304
#define HTTP_STATUS_USE_PROXY                   305
#define HTTP_STATUS_UNUSED                      306
#define HTTP_STATUS_TEMPORARY_REDIRECT          307
#define HTTP_STATUS_BAD_REQUEST                 400
#define HTTP_STATUS_UNAUTHORIZED                401
#define HTTP_STATUS_PAYMENT_REQUEST             402
#define HTTP_STATUS_FORBIDDEN                   403
#define HTTP_STATUS_NOT_FOUND                   404
#define HTTP_STATUS_METHOD_NOT_ALLOWED          405
#define HTTP_STATUS_NOT_ACCEPTABLE              406
#define HTTP_STATUS_PROXY_AUTHONTICATION        407
#define HTTP_STATUS_REQUEST_TIMEOUT             408
#define HTTP_STATUS_CONFLICT                    409
#define HTTP_STATUS_GONE                        410
#define HTTP_STATUS_LENGTH_REQUIRED             411
#define HTTP_STATUS_PRECONDITON_FAILED          412
#define HTTP_STATUS_REQUEST_ENTITY_TOO_LARGE    413
#define HTTP_STATUS_REQUEST_URI_TOO_LONG        414
#define HTTP_STATUS_UNSUPPORTED_MEDIA_TYPE      415
#define HTTP_STATUS_EXPECTATION_FAILED          416
#define HTTP_STATUS_INTERNAL_SERVER_ERROR       500
#define HTTP_STATUS_NOT_IMPLEMENTED             501
#define HTTP_STATUS_BAD_GATEWAY                 502
#define HTTP_STATUS_SERVICE_UNAVAILABLE         503
#define HTTP_STATUS_GATEWAY_TIMEOUT             504
#define HTTP_STATUS_VERSION_NOT_SUPPORTED       505

#define MAX_URI_LENGTH                          4096

// Macros

// Structs
enum http_version
{
    HTTP_0_9, 
    HTTP_1_0, 
    HTTP_1_1
};

enum http_method
{
    OPTIONS, 
    GET, 
    POST, 
    PUT, 
    HEAD, 
    DELETE, 
    TRACE
};

enum cache_control
{
    Public, 
    Private, 
    no_cache, 
    no_store, 
    max_age, 
    min_fresh, 
    max_stale
};

enum request_connection
{
    Close
};

struct http_request_t
{
    // Request line
    char *version;
    char *method;
    char *request_uri;

    // Msg header
    char *cache;
    char *connection;
    char *date;
    char *pragma;
    char *range;

    // Msg content
    char *host;
    char *referer;
    char *user_agent;

    // Common accept
    char *accept;
    char *accept_charset;
    char *accept_encoding;
    char *accept_language;
    char *authorization;

    // raw content
    char *cookie;
    char *raw_post_data;
};

struct http_response_t
{
    // Response header
    char *version;
    char *status_description;
    short http_status;

    // Response content
    char *location;
    char *content_base;
    char *content_encoding;
    char *content_language;
    int content_length;
    char *content_location;
    char *content_md5;
    char *content_range;
    char *content_type;
    char *etag;
    char *expires;
    char *last_modified;

    char original[32768];
};

// Functions

#endif  /* http.h */
